/**
 * Author 罗建武
 * Remark 调取中台基础数据
 */
lyfdefine(function () {
    return ({
        data: function () {
            return {
                purchaseOrderStatusDict: {},    // 采购订单状态
                businessModelList: '',          // 经营模式
                purchaseOrderTypeDict: {},      // 采购订单类型
                orderStatusDict: {},            // 采购单类型
                purchaseAppointStatusDict: {},  // 采购预约状态
                purchaseAppointmentTypeDict: {}, // 采购预约单类型
                purchasePriceStatusDict: {}, // 采购价格状态
                purchasePriceTypeDict: {}, // 采购价格类型
                univalenceTypeDict:{}, // 单价类型
                priceFoundationDict:{} // 计价依据
             }
        },
        mounted() {
            console.log('mixins')
        },
        methods: {
            // 采购订单状态
            getPurchaseOrderStatus() {
                this.$http({
                    url: 'scm-purchase-admin/api/v1/outService/basedata/list',
                    method: 'get',
                    params: {
                        typeCode: 'purchase_order_status'
                    }
                }).then(result => {
                    const data = result.data;
                    if (data && data.code === '0') {
                        let list = data.data.list;
                        for (let i = 0; i < list.length; i++) {
                            this.purchaseOrderStatusDict[list[i].dicKey] = list[i].dicValue
                        }
                    }
                }).catch(() => {
                    console.log('purchase_order_status error')
                })
            },
            // 经营模式
            getBusinessModel() {
                this.$http({
                    url: 'scm-purchase-admin/api/v1/outService/basedata/list',
                    method: 'get',
                    params: {
                        typeCode: 'business_model'
                    }
                }).then(result => {
                    const data = result.data;
                    if (data && data.code === '0') {
                        this.businessModelList = data.data.list;
                    }
                }).catch(() => {
                    console.log('business_model error')
                })
            },
            // 采购订单类型
            getPurchaseOrderType() {
                this.$http({
                    url: 'scm-purchase-admin/api/v1/outService/basedata/list',
                    method: 'get',
                    params: {
                        typeCode: 'purchase_order_type'
                    }
                }).then(result => {
                    const data = result.data;
                    if (data && data.code === '0') {
                        // this.purchaseOrderTypeList = data.data.list;
                        let list = data.data.list;
                        for (let i = 0; i < list.length; i++) {
                            this.purchaseOrderTypeDict[list[i].dicKey] = list[i].dicValue;
                        }
                    }
                }).catch(() => {
                    console.log('business_model error')
                })
            },
            // 采购单类型
            getOrderStatus() {
                this.$http({
                    url: 'scm-purchase-admin/api/v1/outService/basedata/list',
                    method: 'get',
                    params: {
                        typeCode: 'order_status'
                    }
                }).then(result => {
                    const data = result.data;
                    if (data && data.code === '0') {
                        let list = data.data.list;
                        for (let i = 0; i < list.length; i++) {
                            this.orderStatusDict[list[i].dicKey] = list[i].dicValue;
                        }
                    }
                }).catch(() => {
                    console.log('business_model error')
                })
            },
            // 采购预约状态
            getPurchaseAppointStatus() {
                this.$http({
                    url: 'scm-purchase-admin/api/v1/outService/basedata/list',
                    method: 'get',
                    params: {
                        typeCode: 'purchase_appointment_status'
                    }
                }).then(result => {
                    const data = result.data;
                    if (data && data.code === '0') {
                        let list = data.data.list;
                        for (let i = 0; i < list.length; i++) {
                            this.purchaseAppointStatusDict[list[i].dicKey] = list[i].dicValue;
                        }
                    }
                }).catch(() => {
                    console.log('business_model error')
                })
            },
            // 采购预约单类型
            getPurchaseAppointmentType() {
                this.$http({
                    url: 'scm-purchase-admin/api/v1/outService/basedata/list',
                    method: 'get',
                    params: {
                        typeCode: 'purchase_appointment_type'
                    }
                }).then(result => {
                    const data = result.data;
                    if (data && data.code === '0') {
                        let list = data.data.list;
                        for (let i = 0; i < list.length; i++) {
                            this.purchaseAppointmentTypeDict[list[i].dicKey] = list[i].dicValue;
                        }
                    }
                }).catch(() => {
                    console.log('business_model error')
                })
            },
            // 采购价格状态
            getPurchasePriceStatus() {
                this.$http({
                    url: 'scm-purchase-admin/api/v1/outService/basedata/list',
                    method: 'get',
                    params: {
                        typeCode: 'purchase_price_status'
                    }
                }).then(result => {
                    const data = result.data;
                    if (data && data.code === '0') {
                        let list = data.data.list;
                        for (let i = 0; i < list.length; i++) {
                            this.purchasePriceStatusDict[list[i].dicKey] = list[i].dicValue
                        }
                    }
                }).catch(() => {
                    console.log('purchase_price_status error')
                })
            },
            // 单价类型
            getUnivalenceType() {
                this.$http({
                    url: 'scm-purchase-admin/api/v1/outService/basedata/list',
                    method: 'get',
                    params: {
                        typeCode: 'univalenceType'
                    }
                }).then(result => {
                    const data = result.data;
                    if (data && data.code === '0') {
                        let list = data.data.list;
                        for (let i = 0; i < list.length; i++) {
                            this.univalenceTypeDict[list[i].dicKey] = list[i].dicValue
                        }
                    }
                }).catch(() => {
                    console.log('univalenceType error')
                })
            },
            // 采购价格类型
            getPurchasePriceType() {
                this.$http({
                    url: 'scm-purchase-admin/api/v1/outService/basedata/list',
                    method: 'get',
                    params: {
                        typeCode: 'purchase_price_type'
                    }
                }).then(result => {
                    const data = result.data;
                    if (data && data.code === '0') {
                        let list = data.data.list;
                        for (let i = 0; i < list.length; i++) {
                            this.purchasePriceTypeDict[list[i].dicKey] = list[i].dicValue
                        }
                    }
                }).catch(() => {
                    console.log('purchase_price_type error')
                })
            },
            // 计价依据
            getPriceFoundation() {
                this.$http({
                    url: 'scm-purchase-admin/api/v1/outService/basedata/list',
                    method: 'get',
                    params: {
                        typeCode: 'priceFoundation'
                    }
                }).then(result => {
                    const data = result.data;
                    if (data && data.code === '0') {
                        let list = data.data.list;
                        for (let i = 0; i < list.length; i++) {
                            this.priceFoundationDict[list[i].dicKey] = list[i].dicValue
                        }
                    }
                }).catch(() => {
                    console.log('priceFoundation error')
                })
            }
        },
        template: ``
    })
})